<?php
/*************************************************************************
Class Category
----------------------------------------------------------------
PICKCO CMS Project
Company: PICKCO  Co., Ltd  
Email: admin@pick.vn
Last updated: 15/07/2008
**************************************************************************/
class Pick_Core_Category extends Pick_Core_Objects {
	
	function Pick_Core_Category($database = '') {
		if(!$database) {
			global $db;
			$this->_db = $db;
		} else $this->_db = $database;
		$this->objectInfo = "Pick_Core_CategoryInfo";
		$this->table = DB_PREFIX."category";	
	}
/*-----------------------------------------------------------------------*
* Function: cleanTrash xóa tất cả chuyên mục và mẫu tin trong chuyên mục co trang thai la 2
* Parameter: WHERE catproduct
* Return:array ID
*-----------------------------------------------------------------------*/	
	function cleanTrash($condition = '1=1'){
		$dem = 0;
		$objectDelete = $this->getObjects(1, $condition . ' AND status = 2', '', '');
		if($objectDelete) $objectDelete = $objectDelete['data'];
		foreach($objectDelete as $object){
			$arrayIdCategory = $this->getIdSubCategory($object->getField('id'),1);
			$news = new Pick_Dao_News;
			$arrayObject = $news->getObjectsFromArrayCId(1,$arrayIdCategory);
			$this->delete('id IN(' . implode(",", $arrayIdCategory).')  AND status = 2');
		}
		return true;
	}	
}
?>